﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using GaiNo.Core.Result;
using GaiNo.Core.Extensions;
namespace GaiNo.Core.Filters
{
    /// <summary>
    /// 本站POST安全过滤机制
    /// </summary>
    public class IsPostedFromThisSiteActionFilter : AuthorizeAttribute
    {
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            if (filterContext.HttpContext == null)
                return;

            if (filterContext.HttpContext.Request.UrlReferrer == null || !filterContext.HttpContext.Request.UrlReferrer.CurrentDomain())
                filterContext.Result = new UnauthorizedResult();
        }
    }
}
